$(function() {
	admin.orderSplit.init();
});
Namespace('admin.orderSplit', {
	init : function() {
		easyui.util.initDatagrid('#datagrid', {
			onDblClickRow : function() {
				var row = $('#datagrid').datagrid('getSelected');
				admin.orderSplit.detail(row.id);
			}
		});
	},
	query : function() {
		if (!$('#query-form').form('validate'))
			return;
		var data = $('#query-form').form('jsonObject');
		$('#datagrid').datagrid('load', data);
	},
	detail:function(id) {
		if (id != null) {
			top.addTab(id,'订单-分账单详情', contextPath+'/order/split/detail?id=' + id);
		}
	},
	export2Excel : function() {//导出excel
		var url = contextPath + '/order/split/export2Excel';
		var orderNo = $('#orderNo').val();
		var supplierId = $('#supplierId').val();
		var status = $('#status').val();
		var endAtStr = $("input[name=endAtStr]").val();//$('#endAtStr').val();
		var startAtStr = $("input[name=startAtStr]").val();//$('#startAtStr').val();
		//top.showInfo(startAtStr+'---'+endAtStr);
		var params ={};
		var paramstr ="";
		if(orderNo!='' && orderNo!=null){
			paramstr+="&orderNo="+orderNo;
		}
		if(supplierId!='' && supplierId!=null){
			paramstr+="&supplierId="+supplierId;
		}
		if(status!='' && status!=null){
			paramstr+="&status="+status;
		}
		if(startAtStr!='' && startAtStr!=null){
			paramstr+="&startAtStr="+startAtStr;
		}
		if(endAtStr!='' && endAtStr!=null){
			paramstr+="&endAtStr="+endAtStr;
		}
		if(paramstr!=''){
			url += "?"+paramstr;
		}
		window.open(url,"");
		/*
		$.get(url,params,function(result) {
			if(result.code==1) {
				top.showInfo('导出完成!');
			} else {
				top.showInfo('导出失败!'+result.msg);
			}
		});
		*/
	}
});